import { ref } from "vue";
import { parseTime } from "@/utils/ruoyi";
import type { AvueCrudOption } from "@smallwei/avue";

export default function (type: string) {
  const option: AvueCrudOption = {
    rowKey: "menuId",
    align: "center",
    index: true,
    indexLabel: "序号",
    delBtn: false,
    searchShow: false,
    column: [
      {
        prop: "saleUnit",
        label: "售出",
        search: true,
      },
      {
        prop: "chipCode",
        label: "芯片编号",
        search: true,
        hide: true,
      },
      {
        prop: "variety",
        label: "品种",
        search: true,
      },
      {
        prop: "name",
        label: type === "1" ? "猫猫名字" : "狗狗名字",
        search: true,
        rules: [
          {
            required: true,
            message: "请输入名字",
          },
        ],
      },
      {
        prop: "color",
        label: "花色",
        search: true,
      },
      {
        type: "select",
        prop: "sex",
        label: "性别",
        search: true,
        dicUrl: "/api/system/dict/type/optionSelect/pet_sex",
        value: "1",
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
      },
      {
        type: "date",
        prop: "brithday",
        label: "出生日期",
        format: "YYYY-MM-DD",
        width: 100,
      },
      {
        type: "select",
        prop: "hair",
        label: "长短毛",
        dicUrl: "/api/system/dict/type/optionSelect/pet_hair",
        value: "1",
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
      },
      {
        prop: "host",
        label: "主人名字",
      },
      {
        search: true,
        prop: "catteryId",
        label: type === "1" ? "猫舍" : "狗舍",
        type: "select",
        dicUrl: "/api/cattery/list",
        props: {
          label: "name",
          value: "id",
        },
      },
      {
        prop: "shelfNum",
        label: "货架号数",
        search: true,
      },
      {
        type: "select",
        prop: "petStatus",
        label: "宠物状态",
        dicUrl: "/api/system/dict/type/optionSelect/pet_status",
        value: "1",
        props: {
          label: "dictLabel",
          value: "dictValue",
        },
      },
      {
        prop: "createTime",
        label: "创建时间",
        width: 100,
        formatter: (row: any) => {
          return parseTime(row.createTime);
        },
      },
    ],
  };

  return ref(option);
}
